package com.example.zbh.lessona.soundpool;

import android.app.Activity;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;

import com.example.zbh.lessona.R;

import java.io.FileDescriptor;

/**
 * Created by zbh on 15/11/25.
 */
public class SoundPoolActivity extends Activity {
    private SoundPool pool;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sound_pool);
        init();
    }

    private void init() {
        pool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);//最大数目,铃音类型,质量
        int soundId = pool.load(this, R.raw.fallbackring,1);
        pool.play(soundId, 1.0f, 1.0f, 1, -1, 1.0f);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (pool != null){
            pool.release();
            pool = null;
        }
    }
}
